package com.bwie.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.bwie.mapper.ClassMapper;
import com.bwie.pojo.TbClass;
import com.bwie.service.ClassService;
import com.bwie.util.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @program: day0617mounth
 * @ClassName ClassServiceImpl
 * @description:
 * @author: 段阳
 * @create: 2024-06-17 10:09
 **/
@Service
@Transactional
public class ClassServiceImpl implements ClassService {

    @Autowired
    private ClassMapper classMapper;

    @Override
    public R getClassById(Integer id) {
        TbClass tbClass = classMapper.selectOne(new QueryWrapper<TbClass>().lambda().eq(TbClass::getId, id).eq(TbClass::getIsFinish,0));
        return R.success("",tbClass);
    }

    @Override
    public R findClassList(Integer id) {
        if(id!=0){
            List<TbClass> tbClasses = classMapper.selectList(new QueryWrapper<TbClass>().lambda().eq(TbClass::getCollegeId, id).eq(TbClass::getIsFinish, 0));
            return R.success("",tbClasses);
        }else {
            List<TbClass> tbClasses = classMapper.selectList(new QueryWrapper<TbClass>().lambda().eq(TbClass::getIsFinish, 0));
            return R.success("",tbClasses);
        }

    }
}